package com.lhf.dao;

import com.lhf.entity.Person;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.mybatis.spring.annotation.MapperScan;

import java.util.List;

public interface PersonDao {
    @Select("<script>select * from person" +
            "<where>\n" +
            "            <if test=\"name!=null and sex!=null\">\n" +
            "                <if test=\"name!=''\">\n" +
            "                    and name like '${name}%'\n" +
            "                </if>\n" +
            "                <if test=\"sex!='-1'\">\n" +
            "                    and sex=#{sex}\n" +
            "                </if>\n" +
            "            </if>\n" +
            "        </where></script>")
    List<Person>getPerson(@Param("name") String name, @Param("sex") String sex);
    @Select("select introduce from person where id=#{xx}")
    String getxx(int id);
   /* class PersonPropider{
        public String getSql(String name,String sex){
            System.out.println(464+">>>>>>>>>>>");
            String sql="select * from person";
            if (name!=null && sex!=null){
                if (name.equals("") && sex.equals("-1")){
                    *//*sql=sql+"limit 2,2";*//*
                }else if (!name.equals("") && !sex.equals("")){
                    if (sex.equals("-1")){
                        sql=sql+"where name like '%"+name;
                    }else if (sex.equals("0")){
                        sql=sql+"where sex='男' and name like ''
                    }
                }
            }
            return sql;
        }
    }*/
}
